#ifndef __FLOW3DDATA_H__
#define __FLOW3DDATA_H__


#include <gmPoint>
#include <gmContainer>
using GMlib::Vector;

#include <sstream>

enum DATA_TYPE {
  DATA_TYPE_PARTICLE,
  DATA_TYPE_ALL
};


class Flow3DData {
public:
  Flow3DData();
  std::vector< double > const&			getFractionOfFluid();
	float															getAbsVelocityMagnitudeAt( int frame, int x, int y, int z );
  Vector<int,3>											getGridDimensions();
  bool                              isValid() const;
  void                              load( const char* filename, DATA_TYPE type );
  void                              _deserialize(const char* filename);
  int																getNumFrames();

protected:

private:

  bool                                  _valid;

  DATA_TYPE                             _data_type;
  std::vector< double >									_fraction_of_fluid_data;
	std::vector< Vector<float,3> >				_pressure_data;
	std::vector< Vector<float,3> >				_velocity_data; // u,v,w
	float maxVel;
	int																		_num_frames;
	double																originX, originY, originZ;
	int																		grid_size_x, grid_size_y, grid_size_z;
	double																gridSpaceX, gridSpaceY, gridSpaceZ;

	void																	_parse_header(std::istringstream &ss);
	void																	_frame_from_stringstream( std::istringstream &ss, int frame  );
  void                                  _loadData( const char* filename );
	void																	_fast_load( const char* filename );
  void                                  _serialize(const char* filename);
	int																		_get_grid_size(std::istringstream &iss);
};


#endif // __FLOW3DDATA_H__
